<template>
  <div>
    <div>
      <ele-page
        v-loading="loading"
        :formConfig="searchDialog"
        ref="eleTable"
        :operateList="operateList"
        @handleOperateEvent="handleOperateEvent"
        :column="column"
        :getList="getListNew"
        :otherParams="{
          orderStatusInList: '1,2,3,4,7',
          reportWay: 'report_way_unique',
        }"
        uniqueId="mesOtherCodePrinting"
      >
      </ele-page>
    </div>

    <!-- 打印抽屉 -->
    <ele-form-drawer
      :title="$i18n.t('common.print')"
      v-loading="loading"
      :visible.sync="printDialogVisible"
      v-bind="printFormDescDialog"
      v-model="printFormDataDialog"
      size="40%"
      ref="drawerPrint"
    >
      <template v-slot:baseInfo>
        <h3>{{ $i18n.t("mesOtherCodePrinting.baseInfo") }}</h3>
      </template>
      <template v-slot:createInfo>
        <h3>{{ $i18n.t("mesOtherCodePrinting.liveCodeInformation") }}</h3>
      </template>
      <template v-slot:printInfo>
        <h3>{{ $i18n.t("mesOtherCodePrinting.printInformation") }}</h3>
      </template>
      <template v-slot:form-btn="scope">
        <div style="text-align: right; margin-top: 10px">
          <el-button @click="printDialogVisible = false">{{
            $i18n.t("mesOtherCodePrinting.cancel")
          }}</el-button>
          <!-- 清除 -->
          <el-button @click="clearCode" type="danger">{{
            $i18n.t("common.clear")
          }}</el-button>
          <!-- 生码 -->
          <el-button @click="handleCreate" type="primary">{{
            $i18n.t("mesOtherCodePrinting.create")
          }}</el-button>
          <!-- 生码并打印 -->
          <el-button @click="handleCreateAndPrint" type="primary">{{
            $i18n.t("mesOtherCodePrinting.createPrint")
          }}</el-button>
          <!-- 打印 -->
          <el-button @click="handlePrint" type="primary">{{
            $i18n.t("common.print")
          }}</el-button>
          <!-- 补打 -->
          <el-button @click="handleRepairPrint" type="primary">{{
            $i18n.t("mesOtherCodePrinting.reprint")
          }}</el-button>
        </div>
      </template>
    </ele-form-drawer>

    <!-- 选择客商 -->
    <ele-dialog-table
      :title="$i18n.t('mesOtherCodePrinting.choseAMerchant')"
      width="800px"
      :visible.sync="customerDialogVisible"
      :formConfig="customerSearchConfig"
      :column="customerColumn"
      :getList="getCustomerList"
      :hasFooter="true"
      :footer="customerFooter"
      @customEvent="changeCustomerDialog"
      @getSelectData="getSelectCustomer"
    >
    </ele-dialog-table>

    <!-- 选择模板 -->
    <templateSelect
      ref="templateSelect"
      v-model="printFormDataDialog.barcodePrintTempCode"
      :searchData="{
        businessTypeCode: 'PRINT_MES_PC_CUSTOMER_CODE',
      }"
      @select="handleSelectTemplate"
    ></templateSelect>

    <!-- 补打表单弹窗-->
    <ele-form-dialog
      :title="$i18n.t('mesOtherCodePrinting.reprint')"
      v-loading="loading"
      :visible.sync="repairPrintDialogVisible"
      v-bind="repairFormDescDialog"
      v-model="repairFormDataDialog"
      :request-fn="handleSubmitRepair"
      :dialogAttrs="{
        'close-on-click-modal': false,
      }"
      size="50%"
      ref="dialogRepair"
      class="repair-modal"
    >
    </ele-form-dialog>

    <!-- 补打列表抽屉 -->
    <el-drawer
      :title="$i18n.t('mesOtherCodePrinting.make-upList')"
      v-loading="loading"
      :visible.sync="repairListDialogVisible"
      size="50%"
      ref="drawerRepair"
      class="repair-print"
      :destroy-on-close="true"
      :wrapperClosable="false"
    >
      <ele-page
        v-loading="loading"
        :formConfig="repairSearchConfig"
        ref="repairPrintTable"
        :operateList="operateRepairList"
        @handleOperateEvent="handleOperateRepairEvent"
        :column="repairColumn"
        :getList="getRepairPrintList"
        uniqueId="repairPrintTable"
        :otherParams="initRepairForm"
      ></ele-page>
      <div class="dialog-footer2">
        <el-button @click="repairListDialogVisible = false">
          {{ $t("common.cancel") }}
        </el-button>
      </div>
    </el-drawer>

    <!-- 清码弹窗 -->
    <ele-form-dialog
      :title="$i18n.t('mesOtherCodePrinting.coding')"
      v-loading="loading"
      :visible.sync="clearDialogVisible"
      v-bind="clearFormDescDialog"
      v-model="clearFormDataDialog"
      :request-fn="handleSubmitClear"
      width="600px"
      ref="dialogClear"
    >
    </ele-form-dialog>

    <!-- 打印数量弹窗 -->
    <ele-form-dialog
      :title="$i18n.t('mesOtherCodePrinting.printQuantity')"
      v-loading="loading"
      :visible.sync="printNumberVisible"
      v-bind="printNumberFormDescDialog"
      v-model="printNumberFormDataDialog"
      :request-fn="handleSubmitPrintNumber"
      :dialogAttrs="{
        'close-on-click-modal': false,
      }"
      width="600px"
      ref="dialogPrintNumber"
    >
    </ele-form-dialog>
  </div>
</template>

<script>
import { operateList, searchConfig, repairSearchConfig } from "./config";
import {
  getListNew,
  selectCommonProduceRelByProduce,
  genCodeBatch,
  getCodeCount,
  clearOtherCode,
  selectListByConfigurationCode,
  getPrintingTimes,
  splitPrintList,
  getGenCountByCodeType,
} from "@/api/print/mesProdOthercode";
import barcodePrintingAddModel from "./components/barcodePrintingAddModel";
import { getDict, listByConfigRole } from "@/api/common";
import { customerDialog } from "./customerMixin";
import templateSelect from "@/components/templateSelect/index.vue";
import { setPrintData } from "@/utils/judge";
import repairMixin from "@/views/print/mesOtherCodePrinting/repairMixin";

export default {
  name: "mesOtherCodePrinting",
  components: {
    barcodePrintingAddModel,
    templateSelect,
  },
  mixins: [searchConfig, customerDialog, repairSearchConfig, repairMixin],
  data() {
    const _this = this;
    return {
      title: null,
      printDialogVisible: false, // 打印抽屉显示/隐藏
      clearDialogVisible: false, // 清码抽屉显示/隐藏
      isLoading: false,
      loading: false,
      customerDialogVisible: false, // 选择客商弹窗显示/隐藏
      clearFormDataDialog: {}, // 清码表单数据
      printNumberFormDataDialog: {}, // 打印数量表单数据
      operateList,
      getListNew,
      // 列表页字段的绑定配置
      column: [
        {
          type: "selection",
        },
        {
          type: "index",
          label: $i18n.t("common.order"),
          width: 60,
          fixed: "left",
        },
        {
          prop: "planCode",
          label: $i18n.t("mesOtherCodePrinting.planCode"),
          fixed: "left",
          minWidth: 180,
          showOverflowTooltip: true,
        },
        // 生产工单号
        {
          prop: "orderCode",
          label: $i18n.t("mesOtherCodePrinting.orderCode"),
          fixed: "left",
          minWidth: 240,
          showOverflowTooltip: true,
          render: (h, scope) => {
            return (
              <el-link
                type="primary"
                slot="reference"
                style="font-size: 12px;"
                onClick={() => {
                  _this.goChild({ orderCode: scope.row.orderCode });
                }}
              >
                {scope.row.orderCode}
              </el-link>
            );
          },
        },
        // 型号编码
        {
          prop: "prodCode",
          label: $i18n.t("mesOtherCodePrinting.prodCode"),
          minWidth: 130,
          showOverflowTooltip: true,
        },
        // 型号名称
        {
          prop: "prodName",
          label: $i18n.t("mesOtherCodePrinting.prodName"),
          minWidth: 130,
          showOverflowTooltip: true,
        },
        {
          prop: "quantity",
          label: $i18n.t("mesOtherCodePrinting.planQuantity"),
          minWidth: 110,
          showOverflowTooltip: true,
        },
        {
          prop: "actualQuantity",
          label: $i18n.t("mesOtherCodePrinting.actualQuantity"),
          minWidth: 120,
          showOverflowTooltip: true,
        },
        {
          prop: "orderStatus",
          label: $i18n.t("mesOtherCodePrinting.orderStatus"),
          minWidth: 140,
          showOverflowTooltip: true,
          optionProp: {
            value: "value",
            label: "description",
          },
          option: async (data) => {
            const list = await getDict("prod_order_status");
            return list.data.result;
          },
        },
        {
          prop: "planBeginDate",
          label: $i18n.t("mesOtherCodePrinting.planBeginDate"),
          minWidth: 130,
          showOverflowTooltip: true,
        },
        {
          prop: "workshopName",
          label: $i18n.t("common.workshopName"),
          width: 150,
        },
        {
          prop: "lineName",
          label: $i18n.t("common.lineName"),
          width: 120,
          showOverflowTooltip: true,
        },
        {
          prop: "unit",
          label: $i18n.t("mesOtherCodePrinting.measureUnit"),
          minWidth: 110,
          showOverflowTooltip: true,
        },
      ],
      templateList: [], // 打印模板列表
      customerCodeDict: {}, // 分类数据字典，暂时只有客户码
    };
  },
  computed: {
    // 打印表单配置
    printFormDescDialog() {
      const _this = this;
      return {
        span: 24,
        isShowBackBtn: false,
        isShowSubmitBtn: false,
        formDesc: {
          baseInfo: {
            layout: 24,
          },
          orderCode: {
            type: "input",
            label: $i18n.t("mesOtherCodePrinting.orderCode"),
            layout: 12,
            disabled: true,
          },
          goodsCode: {
            type: "input",
            label: $i18n.t("mesOtherCodePrinting.prodCode"),
            layout: 12,
            disabled: true,
          },
          plannedQuantity: {
            // 计划数量
            type: "input",
            label: $i18n.t("mesOtherCodePrinting.plannedQuantity"),
            layout: 12,
            disabled: true,
            default: 1,
          },
          codeType: {
            // 分类
            type: "select",
            label: $i18n.t("mesOtherCodePrinting.codeType"),
            layout: 12,
            prop: {
              value: "value",
              text: "description",
            },
            // optionsLinkageFields: [ "customerCode" ],
            options: async (data) => {
              const list = await getDict("mes_code_type");
              _this.customerCodeDict = list.data.result;
              return list.data.result;
            },
            on: {
              change: async (val) => {
                if (val) {
                  _this.getPrintInfo(val);
                } else {
                  this.$set(this.printFormDataDialog, "quantity", 0);
                  this.$set(this.printFormDataDialog, "quantityPrinted", 0);
                  this.$set(this.printFormDataDialog, "quantityNotPrinted", 0);
                  this.$set(this.printFormDataDialog, "amount", 0);
                  this.$set(
                    this.printFormDataDialog,
                    "barcodePrintTempCode",
                    null
                  );
                  this.$set(this.printFormDataDialog, "barcodePrintTemp", null);
                }
              },
            },
            required: true,
            disabled: false,
          },
          customerCode: {
            // 客商编码
            type: "input",
            label: $i18n.t("mesOtherCodePrinting.customerCode"),
            layout: 12,
            disabled: false,
            slots: {
              append(h) {
                return (
                  <el-button
                    slot="append"
                    icon="el-icon-search"
                    on={{
                      click() {
                        _this.customerDialogVisible = true;
                      },
                    }}
                  ></el-button>
                );
              },
            },
            on: {
              change: (val) => {
                if (!val) {
                  this.$set(this.printFormDataDialog, "customerName", null);
                  this.$set(this.printFormDataDialog, "codeStrategy", null);
                }
              },
            },
          },
          customerName: {
            // 客商名称
            type: "input",
            label: $i18n.t("mesOtherCodePrinting.customerName"),
            layout: 12,
            disabled: true,
          },
          createInfo: {
            layout: 24,
          },
          quantity: {
            // 已生码数量
            type: "number",
            label: $i18n.t("mesOtherCodePrinting.barcodeCreateCount"),
            layout: 12,
            disabled: true,
          },
          codeStrategy: {
            // 编码规则
            type: "select",
            label: $i18n.t("mesOtherCodePrinting.codeStrategy"),
            layout: 12,
            optionsLinkageFields: ["codeType", "customerCode"],
            prop: {
              value: "codeStrategyCode",
              text: "codeStrategyDescription",
            },
            options: async (data) => {
              if (!data.codeType) return;
              const params = {
                goodsCode: data.goodsCode,
                templateType: data.codeType,
                customerCode: data.customerCode,
                type: "codeStrategy",
              };
              const list = await selectCommonProduceRelByProduce(params);
              return list.data.result;
            },
            disabled: (data) => {
              return data.codeType && data.quantity > 0;
            },
          },
          amount: {
            // 生码数量
            type: "number",
            label: $i18n.t("mesOtherCodePrinting.genCount"),
            layout: 12,
            attrs: {
              stepStrictly: true,
              min: 0,
              max:
                parseInt(this.printFormDataDialog["plannedQuantity"]) -
                parseInt(this.printFormDataDialog["quantity"]),
            },
          },
          printInfo: {
            layout: 24,
          },
          quantityPrinted: {
            type: "number",
            label: $i18n.t("mesOtherCodePrinting.quantityPrinted"),
            layout: 12,
            disabled: true,
          },
          quantityNotPrinted: {
            type: "number",
            label: $i18n.t("mesOtherCodePrinting.quantityNotPrinted2"),
            layout: 12,
            disabled: true,
          },
          barcodePrintTemp: {
            type: "input",
            label: $i18n.t("mesOtherCodePrinting.barcodePrintTemp2"),
            layout: 12,
            disabled: (data) => {
              return !!(data.codeType && data.quantityPrinted > 0);
            },
            slots: {
              append(h) {
                return (
                  <el-button
                    disabled={
                      !!(
                        _this.printFormDataDialog.codeType &&
                        _this.printFormDataDialog.quantityPrinted > 0
                      )
                    }
                    slot="append"
                    icon="el-icon-search"
                    on={{
                      click() {
                        _this.$refs.templateSelect.show();
                      },
                    }}
                  ></el-button>
                );
              },
            },
          },
          currentRow: {}, // 表格当前行数据
        },
      };
    },
    // 清码表单配置
    clearFormDescDialog() {
      const _this = this;
      return {
        span: 24,
        isShowBackBtn: false,
        isShowSubmitBtn: true,
        submitBtnText: $i18n.t("mesOtherCodePrinting.clearOtherCode"),
        formDesc: {
          orderCode: {
            type: "input",
            label: $i18n.t("mesOtherCodePrinting.orderCode"),
            layout: 12,
            disabled: true,
          },
          codeType: {
            // 分类
            type: "select",
            label: $i18n.t("mesOtherCodePrinting.codeType"),
            layout: 12,
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getDict("mes_code_type");
              return list.data.result;
            },
            required: true,
            disabled: false,
          },
          clearReason: {
            // 清除原因
            type: "textarea",
            label: $i18n.t("mesOtherCodePrinting.clearReason"),
            layout: 24,
            required: true,
          },
        },
      };
    },
  },
  created() {
    listByConfigRole({
      businessTypeCode: "PRINT_MES_PC_CUSTOMER_CODE",
    }).then((res) => {
      this.templateList = res.data.result || [];
    });
  },
  methods: {
    // 表格顶部按钮操作事件
    handleOperateEvent({ handleName, name, rows }) {
      this.title = name;
      let _this = this;
      const fnc = {
        // 打印
        printBarCode: () => {
          this.currentRow = rows;
          this.printFormDataDialog.orderCode = rows[0].orderCode;
          this.printFormDataDialog.goodsCode = rows[0].prodCode;
          this.printFormDataDialog.plannedQuantity = rows[0].quantity; // 计划数量
          this.printFormDataDialog.barcodePrintTempCodeCache =
            rows[0].barcodePrintTempCode; // 缓存一下打印模版
          this.printDialogVisible = true;
        },
        // 清码
        clearBarcode: () => {
          this.clearFormDataDialog.orderCode = rows[0].orderCode;
          this.clearFormDataDialog.goodsCode = rows[0].prodCode;
          this.clearDialogVisible = true;
        },
        // 补打
        repairPrint: async () => {
          let params = {
            orderCode: rows[0].orderCode,
            codeType: "customer_code",
            configurationCode: "com_customer_code_reviewed",
          };
          let { workshopCode, lineCode } = rows[0];
          if (lineCode) {
            params.levelType = "5";
            params.lineCode = lineCode;
          } else {
            params.levelType = "4";
            params.workshopCode = workshopCode;
          }
          let res = await selectListByConfigurationCode(params);
          this.loading = false;

          this.isNeedCheck =
            res.data.result.length && res.data.result[0].value === "1";
          if (this.isNeedCheck) {
            this.initRepairForm = {
              orderCode: rows[0].orderCode,
              prodCode: rows[0].prodCode,
              prodName: rows[0].prodName,
            };
            this.repairListDialogVisible = true;
          } else {
            this.repairFormDataDialog = {
              id: rows[0].id,
              orderCode: rows[0].orderCode,
              prodCode: rows[0].prodCode,
              prodName: rows[0].prodName,
            };
            this.repairPrintDialogVisible = true;
          }
        },
      };
      fnc[handleName] && fnc[handleName]();
    },
    // 刷新表格数据
    refresh(isReset = true) {
      this.$refs.eleTable.refresh(isReset);
    },
    // 跳转至子页面
    goChild(queryParam) {
      let pathParam = "/print/mesOtherCode";
      this.$router.push({ path: pathParam, query: queryParam });
    },
    // 批量生码
    handleCreate() {
      this.$refs["drawerPrint"].$refs["ele-form"].$refs.form
        .validate()
        .then((valid) => {
          if (valid) {
            if (!!!this.printFormDataDialog.codeStrategy && this.printFormDataDialog['quantity'] < 1 && this.printFormDataDialog['codeType']) {
              this.$message.error(
                $i18n.t("mesOtherCodePrinting.pleaseSelectCodeRules")
              );
              return;
            }
            if (this.printFormDataDialog.amount <= 0) {
              this.$message.error(
                $i18n.t(
                  "mesProdOtherCode.theNumberOfRawCodesMustBeGreaterThan0"
                )
              );
              return;
            }
            this.$refs["drawerPrint"].$refs["ele-form"].$refs.form
              .validate()
              .then((valid) => {
                const data = {
                  orderCode: this.printFormDataDialog.orderCode,
                  codeType: this.printFormDataDialog.codeType,
                  codeStrategy: this.printFormDataDialog.codeStrategy,
                  amount: this.printFormDataDialog.amount,
                  customerCode: this.printFormDataDialog.customerCode,
                  customerName: this.printFormDataDialog.customerName,
                };
                this.loading = true;
                genCodeBatch(data)
                  .then((res) => {
                    if (res.data.success) {
                      const message = res.data.message;
                      this.$message.success(
                        message ||
                          this.$i18n.t("mesOtherCodePrinting.createSuccess")
                      );
                      this.refresh();
                    } else {
                      this.$message.warning(res.data.message);
                    }
                  })
                  .finally(() => {
                    this.loading = false;
                    this.printDialogVisible = false;
                  });
              });
          }
        });
    },
    // 选择打印标签模板
    handleSelectTemplate(data) {
      this.$set(
        this.printFormDataDialog,
        "barcodePrintTempCode",
        data.tempCode
      );
      this.$set(this.printFormDataDialog, "barcodePrintTemp", data.tempName);
    },
    // 清码表单提交
    handleSubmitClear(data) {
      this.loading = true;
      clearOtherCode(data)
        .then((res) => {
          if (res.data.success) {
            this.$message.success(
              $i18n.t("mesOtherCodePrinting.clearCodeSuccess")
            );
          }
        })
        .finally(() => {
          this.clearDialogVisible = false;
          this.printDialogVisible = false;
          this.loading = false;
        });
    },
    // 清码按钮动作
    clearCode() {
      this.$refs["drawerPrint"].$refs["ele-form"].$refs.form
        .validate()
        .then((valid) => {
          if (valid) {
            if (parseInt(this.printFormDataDialog.quantity) <= 0) {
              const customerCode = this.customerCodeDict.find(
                (item) => item.value === this.printFormDataDialog.codeType
              )?.description;
              this.$message.error(
                $i18n.t("mesOtherCodePrinting.noClearanceAvailable") +
                  `${customerCode}`
              );
              return;
            }
            this.clearFormDataDialog["orderCode"] =
              this.printFormDataDialog.orderCode;
            this.clearDialogVisible = true;
          }
        });
    },
    // 生码并打印
    handleCreateAndPrint() {
      this.$refs["drawerPrint"].$refs["ele-form"].$refs.form
        .validate()
        .then((valid) => {
          if (valid) {
            if (!!!this.printFormDataDialog.codeStrategy) {
              this.$message.error(
                $i18n.t("mesOtherCodePrinting.pleaseSelectCodeRules")
              );
              return;
            }
            if (this.printFormDataDialog.amount <= 0) {
              this.$message.error(
                $i18n.t(
                  "mesProdOtherCode.theNumberOfRawCodesMustBeGreaterThan0"
                )
              );
              return;
            }
            if (!!!this.printFormDataDialog.barcodePrintTempCode) {
              this.$message.error(
                $i18n.t("mesOtherCodePrinting.pleaseSelectTheLabelTemplate")
              );
              return;
            }
            this.$refs["drawerPrint"].$refs["ele-form"].$refs.form
              .validate()
              .then((valid) => {
                const data = {
                  orderCode: this.printFormDataDialog.orderCode,
                  codeType: this.printFormDataDialog.codeType,
                  codeStrategy: this.printFormDataDialog.codeStrategy,
                  amount: this.printFormDataDialog.amount,
                  customerCode: this.printFormDataDialog.customerCode,
                  customerName: this.printFormDataDialog.customerName,
                };
                genCodeBatch(data).then((res) => {
                  if (res.data.success) {
                    this.maxPrintNumber =
                      parseInt(this.printFormDataDialog.amount) +
                      parseInt(this.printFormDataDialog.quantityNotPrinted);
                    this.$set(
                      this.printNumberFormDataDialog,
                      "amount",
                      this.maxPrintNumber
                    ); // 设置默认值为可打印的最大值
                    this.printNumberVisible = true;
                  } else {
                    this.$message.warning(res.data.message);
                  }
                });
              });
          }
        });
    },
    // 打印数量弹窗
    handlePrint() {
      this.$refs["drawerPrint"].$refs["ele-form"].$refs.form
        .validate()
        .then((valid) => {
          if (valid) {
            if (!this.printFormDataDialog["barcodePrintTempCode"]) {
              this.$message.error(
                $i18n.t("mesOtherCodePrinting.pleaseSelectTheLabelTemplate")
              );
              return;
            }
            if (this.printFormDataDialog["quantityNotPrinted"] <= 0) {
              this.$message.error($i18n.t("mesOtherCodePrinting.noCodeToPrint"));
              return;
            }
            this.maxPrintNumber = parseInt(
              this.printFormDataDialog.quantityNotPrinted
            );
            this.$set(
              this.printNumberFormDataDialog,
              "amount",
              this.maxPrintNumber
            ); // 设置默认值为可打印的最大值
            this.printNumberVisible = true;
          }
        });
    },
    // 打印提交
    handleSubmitPrintNumber() {
      this.printNumberVisible = false;
      const params = {
        isPrint: 0,
        orderCode: this.printFormDataDialog.orderCode,
        amount: this.printNumberFormDataDialog.amount,
        barcodePrintTemp: this.printFormDataDialog.barcodePrintTemp,
        barcodePrintTempCode: this.printFormDataDialog.barcodePrintTempCode,
        codeType: this.printFormDataDialog.codeType,
      };
      splitPrintList(params).then((res) => {
        setPrintData(
          {
            code: this.printFormDataDialog.barcodePrintTempCode,
            name: this.printFormDataDialog.barcodePrintTemp,
            status: 0, // 0:打印，1:补打
          },
          res.data.result
        );
        this.printDialogVisible = false;
        this.printNumberVisible = false;
        this.$router.push("/splitPrint");
      });
    },
    // 补打
    handleRepairPrint() {
      this.$refs["drawerPrint"].$refs["ele-form"].$refs.form
        .validate()
        .then((valid) => {
          if (valid) {
            if (this.printFormDataDialog.quantityPrinted <= 0) {
              this.$message.error($i18n.t("mesOtherCodePrinting.noCodesToMakeUp"));
              return;
            }
            this.printDialogVisible = false;
            this.handleOperateEvent({
              handleName: "repairPrint",
              rows: this.currentRow,
            });
          }
        });
    },
    // 根据类型和客户编码获取打印信息
    async getPrintInfo(codeType) {
      const params = {
        orderCode: this.printFormDataDialog.orderCode,
        codeType: codeType,
      };
      const response = await getCodeCount(params);
      this.$set(
        this.printFormDataDialog,
        "quantity",
        response.data.result["quantity"]
      );
      this.$set(
        this.printFormDataDialog,
        "quantityPrinted",
        response.data.result["quantityPrinted"]
      );
      this.$set(
        this.printFormDataDialog,
        "quantityNotPrinted",
        response.data.result["quantityNotPrinted"]
      );
      this.$set(
        this.printFormDataDialog,
        "amount",
        parseInt(this.printFormDataDialog["plannedQuantity"]) -
          parseInt(response.data.result["quantity"])
      );
      this.$set(
        this.printFormDataDialog,
        "codeStrategy",
        response.data.result["codeStrategyCode"]
      );
      // 如果已打印过，就无法修改标签模版，只能使用之前打印的模板进行打印
      if (parseInt(response.data.result["quantityPrinted"]) > 0) {
        this.$set(
          this.printFormDataDialog,
          "barcodePrintTempCode",
          response.data.result["barcodePrintTempCode"]
        );
        this.$set(
          this.printFormDataDialog,
          "barcodePrintTemp",
          response.data.result["barcodePrintTemp"]
        );
      }
    },
  },
};
</script>

<style lang="scss" scoped>
h3 {
  font-size: 16px;
  height: 16px;
  line-height: 16px;
  margin: 20px 0 6px 0;
  font-weight: bolder;
}

h3::before {
  content: "";
  display: inline-block;
  background-color: #0f9e5e;
  width: 6px;
  height: 14px;
  line-height: 14px;
  margin: 0px 8px -1px 0px;
  border-radius: 2px;
}
.repair-print {
  /deep/ .el-drawer__body {
    padding: 10px;
  }

  /deep/ .ele-form-search {
    height: auto !important;
  }
}
/deep/ .el-form-item--small.el-form-item {
  margin-bottom: 8px;
}
.repair-modal /deep/ .el-form-item--small.el-form-item {
  margin-bottom: 18px;
}
.dialog-footer2 {
  padding-top: 0px;
  display: flex;
  justify-content: flex-start;
  margin-top: -35px;
}
</style>
